<?php 

###########################################################################
#   Copyright (C) 2012 CDNPAL LTD by Christopher Gu                       #
#   resources@cdnpal.com                                                  #
#                                                                         #
#   coded for Php 4.3/5.X and above                                       #
#   and AllowOverride all for .htaccess                                   #
#                                                                         #
#   This program is free software released                                #
#   under the GPL version 2 license:                                      #
#   http://www.gnu.org/licenses/gpl-2.0.htm                               #
#                                                                         #
#   This program is distributed WITHOUT ANY WARRANTY                      #
#   or FITNESS FOR A PARTICULAR PURPOSE.                                  #
#                                                                         #
#   DADF-SDK                                                              #
#                                                                         #
###########################################################################

abstract class GenericDataObject extends Zend_Db_Table_Abstract {

	protected $_primary;
	protected $_name;
	protected $_sequence = true;
	protected $_current_row = null;

    function __construct($_row = null) {
	    parent::__construct();
    	if ($_row == null):
	        $this->_current_row = $this->fetchNew();
	    else:
	    	$this->_current_row = $_row;
	    endif;
    	
    }

	function __get($name) {	
		if (strpos($name, 'class_member_only_') === false):
			return isset($this->_current_row->$name) ? $this->_current_row->$name : null;
		else:
			return $this->$name;
		endif;
	}
	
	function __set($name, $val) {	
		if (strpos($name, 'class_member_only_') === false):
			$this->_current_row->$name = $val;
		else:
			$this->$name = $val;
		endif;
	}
	
	function set_row($RowID) {	
		$this->_current_row = $this->find($RowID)->current();
	}
	
	function save() {
		$this->_current_row->save();
	}
};
